Skip to content

simd(avx2): fix F64x8::reduce_min/max regression from #435 + before/after disassembly write-up - #437

Merged
AdaWorldAPI merged 4 commits into
masterfrom
claude/practical-newton-u8lir8
Nov 17, 2026
Merged

AdaWorldAPI merged 4 commits into
masterfrom
claude/practical-newton-u8lir8

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

These three commits were pushed after #436 had already been merged, so they did not reach master. The updated description on #436 mentioned them, but only the Mandelbrot table (§ 6) was merged.

Code (src/simd_avx2.rs, one method pair)

  • The AVX2 F64x8::reduce_min / reduce_max return to master's original body: an iterator fold over the fixed-size lane array, which is the shape simd_ops is built on.
  • simd: additive float/mask/integer API on every backend + IEEE bit-exact CI gate (+ wide/pulp inventory docs) #435 had replaced that body with a hand-written vminpd/vblendvpd tree. The before/after probe showed the tree to be 1.9× slower: 2.15 → 4.03 ns per call, and 21 → 27 instructions.
  • With the fold restored, the method is back to about 2.0 ns and 21 instructions.
  • Results are bit-identical in all three versions. No AVX-512 code is touched.

Docs (.claude/knowledge/simd-crate-comparison-wide-pulp-2026-11-17.md §§ 7–8, blackboard)

§ 7: #435 before and after, per method (llvm-objdump plus timing)

  • On AVX-512, all 30 probe symbols are identical before and after.
  • On AVX2, LLVM had already vectorized master's lane loops, so most of the rewrite is neutral.
  • The real AVX2 gains are U8x64::mask_blend (10×), F32x16 compare + select (2.4×) and the F32x16 reductions (1.6×).
  • The f64 reductions regressed. The code change above fixes that.

§ 8: Mandelbrot follow-up

  • On AVX-512, the ndarray and wide8 inner loops are identical, instruction for instruction.
  • The 9% gap was in the benchmark arm: a saturating float-to-int cast done one lane at a time. With an exact 2^52 add and to_bits(), ndarray takes 149–154 ms, against 152–157 ms for wide8 and 155–156 ms for pulp.
  • On AVX2, ndarray is still behind. The compare result is packed into the public bitmask and expanded again for select.

Verification

  • Parity tests: tests/simd_lane_masks (including the NaN compatibility tests) and simd_float_classify pass on v3 and avx.
  • Lib tests: 2692 passed on v3.
  • masking-parity: passes on pinned v3 and on avx-qemu, with the IEEE digest unchanged.
  • Static checks: clippy -D warnings, fmt, the facet-stride guard and the ternlog generator check are all clean.

Generated by Claude Code

Adds section 7 to the wide/pulp comparison and a blackboard entry. AVX-512:
all 30 probe symbols are identical before and after. AVX2: LLVM had already
vectorized master's lane loops, so most of the F2 rewrite is neutral; the
compares are 3 instructions longer; F64x8::reduce_min/max regressed 1.9x;
real gains are U8x64::mask_blend (10x), F32x16 compare+select (2.4x) and
F32x16 reductions (1.6x). Docs only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMQaYXab73XQdjqZfAW
…_max

PR #435 replaced it with a hand-written NaN-ignoring vminpd/vblendvpd tree
through the 256-bit halves, which the before/after probe showed to be 1.9x
slower (2.15 -> 4.03 ns per call, 21 -> 27 instructions). The original body,
an iterator fold over the fixed-size lane array (the shape simd_ops is built
on), lowers to a short vminsd chain. Results are bit-identical either way.

Verified: probe back to ~2.0 ns and 21 instructions, result fingerprint
unchanged; tests/simd_lane_masks (incl. the NaN compatibility tests) and
simd_float_classify pass on v3 and avx; lib 2692 passed on v3; masking-parity
with the IEEE digest passes on pinned v3 and avx-qemu; clippy, fmt, guard
and the ternlog generator check clean. AVX-512 code is untouched.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMQaYXab73XQdjqZfAW
… the fix

Section 8 of the wide/pulp comparison and a blackboard entry: the ndarray
and wide8 inner loops are instruction-identical on x86-64-v4; the gap was a
per-lane saturating float-to-int cast in the arm. With an exact 2^52 add and
to_bits() the arm is level with wide and pulp on AVX-512. Docs only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMQaYXab73XQdjqZfAW
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 072c7b41-6fc3-4856-a61d-e4bd9e00dd41
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review November 17, 2026 18:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T18:43:24.799621Z 28c1579 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AdaWorldAPI
AdaWorldAPI merged commit c790bd9 into master Nov 17, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants